package top.llove.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import top.llove.service.KindService;
import top.llove.utils.res.ApiResult;

/**
 * 文章分类Controller
 *
 * @author: 幸会
 * @date: 2021/6/22 14:51
 * @email: 1846724873@qq.com
 * @description: 文章分类Controller
 * version: 1.0
 */
@RestController
@RequestMapping("/kind")
public class KindController {

    @Autowired
    private KindService kind;

    /**
     * 添加文章分类
     * @param name 分类名称
     * @param user 分类所属管理员
     * @return
     */
    @PostMapping("/xh/s")
    public ApiResult save(@RequestParam(value = "n", required = true) String name,
                          @RequestParam(value = "u", required = true) String user) {
        return kind.save(name, user);
    }

    /**
     * 传文章分类
     * @param user 管理员id
     * @return
     */
    @GetMapping("/q")
    public ApiResult query(@RequestParam(value = "u", required = false) String user) {
        return kind.query(user);
    }

    /**
     * 删除文章分类
     * @param id 分类id
     * @param user 管理员id
     * @return
     */
    @PostMapping("/d")
    public ApiResult delete(@RequestParam(value = "i", required = false) String id,
                            @RequestParam(value = "u", required = false) String user) {
        return kind.delete(id, user);
    }

}
